package com.atstudy.files;

import java.io.File;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/29 15:29
 * @copyright: 博为峰
 */
public class DG {
    public static void main(String[] args) {
        /*for (int i = 0; i < 5; i++) {
            System.out.println(i);
        }*/
//        m1(5);
//        m2();
        File dir = new File("C:\\Users\\admin\\Desktop\\java29\\io\\a");
        m3(dir);
    }

    private static void m3(File dir) {
        File[] files = dir.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                m3(file);
            } else {
                file.delete();
            }
        }
        dir.delete();
    }

    private static void m2() {
        File dir = new File("C:\\Users\\admin\\Desktop\\java29\\io\\a");
        File[] files = dir.listFiles();
        for (File file : files) {
            if (file.isDirectory()) {
                File[] files1 = file.listFiles();
                for (File file1 : files1) {
                    if (file1.isDirectory()) {
                        File[] files2 = file1.listFiles();
                        for (File file2 : files2) {
                            if (file2.isDirectory()) {

                            }
                        }
                    } else {
                        file1.delete();
                    }
                }
            } else {
                file.delete();
            }
        }
    }

    public static void m1(int i) {
        System.out.println(i);
        i--;
        if (i > 0) {
            m1(i);
        }
    }
}
